<?php
/**
 * @desc 手机验证码
 */
namespace App\Rules;

use Illuminate\Contracts\Validation\Rule;
use Cache;

class SecuriytCode implements Rule
{
    /**
     * Create a new rule instance.
     *
     * @return void
     */
	public function __construct($mobile)
    {
    	$this->mobile = $mobile;
    }

    /**
     * Determine if the validation rule passes.
     *
     * @param  string  $attribute
     * @param  mixed  $value
     * @return bool
     */
    public function passes($attribute, $value)
    {
    	logger(Cache::get('securiyCode_'.$this->mobile));
    	$result = Cache::get('securiyCode_'.$this->mobile) == $value;
    	return $result;
    }

    /**
     * Get the validation error message.
     *
     * @return string
     */
    public function message()
    {
        return '手机验证码不正确';
    }
}
